package com.blrs.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.blrs.common.utils.SecurityUtils;
import com.blrs.common.utils.uuid.UUID;
import com.blrs.service.enterprise.electric.IElectricSalesFollowRecordsService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.blrs.common.annotation.Log;
import com.blrs.common.core.controller.BaseController;
import com.blrs.common.core.domain.AjaxResult;
import com.blrs.common.enums.BusinessType;
import com.blrs.domain.ElectricSalesFollowRecords;
import com.blrs.common.core.page.TableDataInfo;

/**
 * 电销更进记录Controller
 * 
 * @author zhongliang.yang
 * @date 2023-08-15
 */
@RestController
@RequestMapping("/electricSalesFollowRecords/records")
public class ElectricSalesFollowRecordsController extends BaseController
{
    @Autowired
    private IElectricSalesFollowRecordsService electricSalesFollowRecordsService;

    /**
     * 查询电销更进记录列表
     */
    //@PreAuthorize("@ss.hasPermi('electricSalesFollowRecords:records:list')")
    @GetMapping("/list")
    public TableDataInfo list(ElectricSalesFollowRecords electricSalesFollowRecords)
    {
        startPage();
        List<ElectricSalesFollowRecords> list = electricSalesFollowRecordsService.selectElectricSalesFollowRecordsList(electricSalesFollowRecords);
        return getDataTable(list);
    }


    /**
     * 获取电销更进记录详细信息
     */
    //@PreAuthorize("@ss.hasPermi('electricSalesFollowRecords:records:query')")
    @GetMapping(value = "/{recordsId}")
    public AjaxResult getInfo(@PathVariable("recordsId") String recordsId)
    {
        return success(electricSalesFollowRecordsService.selectElectricSalesFollowRecordsByRecordsId(recordsId));
    }

    /**
     * 新增电销更进记录
     */
    //@PreAuthorize("@ss.hasPermi('electricSalesFollowRecords:records:add')")
    @Log(title = "电销更进记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ElectricSalesFollowRecords electricSalesFollowRecords)
    {
        electricSalesFollowRecords.setRecordsId(UUID.randomUUID().toString().replaceAll("-", ""));
        electricSalesFollowRecords.setFollowId(SecurityUtils.getUserId());
        return toAjax(electricSalesFollowRecordsService.insertElectricSalesFollowRecords(electricSalesFollowRecords));
    }

    /**
     * 修改电销更进记录
     */
    //@PreAuthorize("@ss.hasPermi('electricSalesFollowRecords:records:edit')")
    @Log(title = "电销更进记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ElectricSalesFollowRecords electricSalesFollowRecords)
    {
        return toAjax(electricSalesFollowRecordsService.updateElectricSalesFollowRecords(electricSalesFollowRecords));
    }

    /**
     * 删除电销更进记录
     */
    //@PreAuthorize("@ss.hasPermi('electricSalesFollowRecords:records:remove')")
    @Log(title = "电销更进记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{recordsIds}")
    public AjaxResult remove(@PathVariable String[] recordsIds)
    {
        return toAjax(electricSalesFollowRecordsService.deleteElectricSalesFollowRecordsByRecordsIds(recordsIds));
    }
}
